<!DOCTYPE html>
<html>
	<!-- 动态组件 -->
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue2.6.12.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
				<keep-alive >
					<component :is="com"></component>
				</keep-alive>
				<button @click="ch">child</button>
				<button @click="ch1">child1</button>
		</div>
	</body>
	<script type="text/javascript">
		Vue.component('child',{
			template:`
				<div>
					child
				<div>
			`,
		}),
		Vue.component('child1',{
			template:`
				<div>
					<input type="text">
					<button>提交</button>
				</div>
			`
		})
		
		var vm = new Vue({
			el:'#app',
			data:{
				com:"child"
			},
			methods:{
				ch(){
					console.log('child');
					this.com='child';
				},
				ch1(){
					console.log('child1')
					this.com='child1';
				}
			}
		});
	</script>
</html>
